package com.enhe.gck.fg;

import com.enhe.gck.communal.PublicMethod;
import com.enhe.gck.communal.PublicReturn;
import com.kuangkie.carbon.fg.ops.ProRecordOpsBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import com.kuangkie.carbon.fg.FuncGroupContext;
import com.kuangkie.carbon.fg.ImproveResultFactory;
import com.kuangkie.carbon.fg.SecondRoundImproveFuncGroup;
import com.kuangkie.carbon.record.FGRecordComplexus;
import com.kuangkie.carbon.record.ProRecord;
import com.enhe.gck.CarbonBaseConstant; //模型Code
import com.enhe.gck.CarbonEnumKeyValue; //枚举字典信息
import com.enhe.gck.CarbonRelationType; //关系类型Code
import com.enhe.gck.item.OperationLogHWANE21797Item; // 模型属性Code

@Repository(value = "hwane21797366042330866425862")
@Slf4j
public class OperationLogHWANE21797BNB implements SecondRoundImproveFuncGroup{
	
	@Override
	public void secondImprove(FuncGroupContext context, ProRecord proRecord, FGRecordComplexus recordComplexus,
			ImproveResultFactory improveResultFactory) {
		if (proRecord.isNew()){
			if(context.getUserCode()!=null){
				improveResultFactory.getCurrentProRecordOpsBuilder().addRelation(CarbonRelationType.RR_操作记录_操作用户_系统用户, context.getUserCode());
			}
		}
	}


	public static void save(ImproveResultFactory improveResultFactory,int re, int type,String id) {
		save(improveResultFactory,re, type,id,null);
	}

	public static void save(ImproveResultFactory improveResultFactory,int re, int type,String id,String remark) {
		Long reId=null;
		switch (re) {
			case 1:
				reId=CarbonRelationType.RR_操作记录_充值信息_充值记录;
				break;
			case 2:
				reId=CarbonRelationType.RR_操作记录_过磅记录_过磅信息;
				break;
			case 3:
				reId=CarbonRelationType.RR_操作记录_开票管理_开票记录;
				break;
			case 4:
				reId=CarbonRelationType.RR_操作记录_供货计划_供货计划;
				break;
			case 5:
				reId=CarbonRelationType.RR_操作记录_供货订单_供货订单;
				break;
			case 6:
				reId=CarbonRelationType.RR_操作记录_订单记录_订单记录;
				break;
			case 7:
				reId=CarbonRelationType.RR_操作记录_倒料订单_倒料订单;
				break;
			case 8:
				reId=CarbonRelationType.RR_操作记录_开单记录_开单记录;
				break;
			case 9:
				reId=CarbonRelationType.RR_操作记录_客户管理_客户管理;
				break;
		}

		Long code =null;
		switch (type) {
			case 1:
				code=CarbonEnumKeyValue.操作类型_创建_cj;
				break;
			case 2:
				code=CarbonEnumKeyValue.操作类型_修改_xg;
				break;
			case 3:
				code=CarbonEnumKeyValue.操作类型_作废_zf;
				break;
			case 4:
				code=CarbonEnumKeyValue.操作类型_退货_th;
				break;
			case 5:
				code=CarbonEnumKeyValue.操作类型_删除_sc;
				break;
			case 6:
				code=CarbonEnumKeyValue.操作类型_装货_zh;
				break;
			case 7:
				code=CarbonEnumKeyValue.操作类型_还卡_hk;
				break;
			case 8:
				code=CarbonEnumKeyValue.操作类型_异常通过_yctg;
				break;
			case 9:
				code=CarbonEnumKeyValue.操作类型_退款_tk;
				break;
			case 10:
				code=CarbonEnumKeyValue.操作类型_余额消除_yexc;
				break;
		}
		if(reId!=null&&code!=null){
			improveResultFactory.getProRecordOpsBuilder(CarbonBaseConstant.操作记录_czjl)
					.addRelation(reId,id)
					.putAttribute(OperationLogHWANE21797Item.基本属性组_类型, code)
					.putAttribute(OperationLogHWANE21797Item.基本属性组_备注, remark);
		}
	}
}
